<template>
  <div id="building">
    <div class="login_box">
      <!-- 登录表单区域 -->
      <!--ruleForm      -->
      <el-form size="mini" :model="ruleForm" >
        <!-- 用户名 -->
        <el-form-item  prop="username">
          <el-input
            v-model="ruleForm.username"
            placeholder="账号" prefix-icon="iconfont icon-user">
          </el-input>
        </el-form-item>
        <!-- 密码 -->
        <el-form-item prop="password">
          <el-input type="password" v-model="ruleForm.password"
                    placeholder="密码" prefix-icon="iconfont icon-user" >
          </el-input>
        </el-form-item>
        <!-- 记住我 -->
        <el-form-item>
          <el-checkbox label="记住我" class="rememberMe"></el-checkbox>
        </el-form-item>
        <!-- 登录按钮 -->
        <el-form-item>
          <el-button type="primary" @click="submitForm()">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  export default {
    name: "Login",
    data() {
      return {
        ruleForm: {},
      };
    },
    methods: {
      submitForm() {
        //get
        // this.$axios.get("http://localhost:8089/111/111?id=12345")
        //   .then(result=>{
        //     console.log(response.data);
        //   })
        //   .catch(result=>{
        //     console.log(error);
        //   })
        // console.log(this.ruleForm);
        // post
        this.$http.post("/user/login",this.ruleForm)
          .then(result=>{
            // 跳转到列表页
            this.$router.push({ path: "/about" });
            console.log(result)
          })
          .catch(result=>{
            console.log(this.ruleForm)
            // 跳转到列表页
            // 请求失败
            this.$message({
              message: '网络错误',
              type: 'error'
            });
            // console.log(result);
            this.$router.push({ path: "/about" });
          })
      },
    },
  };
</script>

<style >
  #building {
    background: url("../assets/3.jpeg");
    width: 100%;
    height: 100%;
    position: fixed;
    background-size: 100% 100%;
  }
  .login_container {
    background-image: linear-gradient(-180deg, #1a1454 0%, #0e81a5 100%);
    /*background-image: url("../images/bg_login.png");*/
    background-repeat: no-repeat;
    background-size: cover;
    height: 100%;
  }
  .login_box {
    width: 290px;
    height: 350px;
    /* background-color: #fff; */
    background-color: #2e527bb3;
    border-radius: 5px;

    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .el-form {
    padding: 32px;
    position: absolute;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .el-button {
    width: 100%;
  }
  .code {
    width: 45%;
  }
</style>
